<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>flex布局</title>
  <style>
    body {
      padding: 0;
      margin: 0;
    }

    ul,
    li {
      list-style: none;
      margin: 0;
      padding: 0;
    }
    ul{
      display: flex;
    }
    li{
      padding:10px;
      border-right: 1px solid #000;
    }
    .title{
      text-align: center;
      font-size: 40px;
      font-weight: bold;
      border-bottom: 1px solid #000;
      background-color:goldenrod;
      padding: 10px 0;
    }
    h1,h2{
      text-align: center;
    }
    .box,.box1 {
      width: 200px;
      height: 100px;
      border: 1px solid #000;
      display: flex;
      margin: 10px auto;

    }

    .item {
      width: 30px;
      height: 30px;
      background-color: orange;
      border: 1px solid blue;
      text-align: center;
      line-height: 30px;

    }

    .box:nth-of-type(1) {
      justify-content: flex-start;
    }

    .box:nth-of-type(2) {
      justify-content: flex-end;
    }

    .box:nth-of-type(3) {
      justify-content: center;
    }

    .box:nth-of-type(4) {
      justify-content: space-between;
    }


    .box:nth-of-type(5) {
      justify-content: space-around;
    }

    .box:nth-of-type(6) {
      justify-content: space-evenly;
    }

    .box:nth-of-type(7) {
      justify-content: stretch;
    }
    

    .box1:nth-of-type(1){
      align-items: flex-start;
    }
    .box1:nth-of-type(2){
      align-items: flex-end;
    }
    .box1:nth-of-type(3){
      align-items:stretch;
    }
    .box1:nth-of-type(4){
      align-items:center;
    }
    .box1:nth-of-type(5){
      align-items:baseline;
    }
  </style>
</head>

<body>
  <div class="title">flex 布局</div>
  <ul>
    <li title="justify-content 对齐方式" >
      <h1>  justify-content 水平对齐方式</h1>
      <h2>flex-start 居左开始位置</h2>
      <div class="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>flex-end 居右结束位置</h2>
      <div class="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>center 垂直居中对齐</h2>
      <div class="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>space-between 两端对齐 中间居中对齐</h2>
      <div class="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>space-around 两端间距小 中间间距大</h2>
      <div class="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>space-evenly 平均分配间距</h2>
      <div class="box">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>stretch 子元素未设置高度会自动撑满</h2>
      <div class="box">
        <div class="item">1</div>
        <div class="item" style="height:auto">2</div>
        <div class="item">3</div>
      </div>
    </li>
    <li title="algin-items 垂直对齐方式" >
      <h1>  algin-items 对齐方式</h1>
      <h2>flex-start 居左开始位置</h2>
      <div class="box1">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>flex-end 居右结束位置</h2>
      <div class="box1">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>stretch 若没设置高度 自动撑满</h2>
      <div class="box1">
        <div class="item">1</div>
        <div class="item" style="height: auto;">2</div>
        <div class="item">3</div>
      </div>
      <h2>center  垂直居中对齐</h2>
      <div class="box1">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
      </div>
      <h2>baseline 文字底部对齐</h2>
      <div class="box1">
        <div class="item">1</div>
        <div class="item" style="font-size: 40px;">2</div>
        <div class="item">3</div>
      </div>
      
    </li>
  </ul>



</body>

</html>